﻿using System.Collections;

using GameServer.Virtual_Objects.User;
using GameServer.Virtual_Objects.Room;

namespace GameServer.Networking.Packets
{
    class PACKET_INIT_PLAYER : Packet
    {
        public PACKET_INIT_PLAYER(virtualRoom Room)
        {
            try
            {
                newPacket(30017);

                addBlock(Room.PlayerCount);
                foreach (virtualUser Player in Room.Players)
                {
                    if (Player != null)
                    {
                        addBlock(Player.RoomSlot);
                        addBlock(Player.Health);
                        addBlock(-1);
                        addBlock(-1);
                        addBlock(-1);
                    }
                }
                //Object Related
                if (Room.VehiclesChecked == false)
                    addBlock(0);
                else
                {
                    addBlock(Room.Vehicles.Length);
                    foreach (Vehicle Object in Room.Vehicles)
                    {
                        addBlock(Object.Health);
                        addBlock(Object.MaxHealth);
                    }
                }
            }
            catch
            {
                Log.WriteError("Error on packet_ini_player");
            }
        }
    }
}